﻿using AgencyManagerSystem.Common;
using System;
using System.Collections.Generic;

namespace AgencyManagerSystem.DataUpdater
{
    public class DataUpdatingEventArgs<T> : EventArgs where T : DBModel
    {
        public bool Cancel { get; set; }
        public string Message { get; set; }
        public T Insert { get; set; }
        public T Delete { get; set; }
    }
    public class DataBulkUpdatingEventArgs<TMain,TDetail> : EventArgs  where TDetail : DBModel where TMain : DBModel
    {
        public bool Cancel { get; set; }
        public string Message { get; set; }
        public TMain Insert { get; set; }
        public IEnumerable<TDetail> DetailInsert { get; set; }
        public IEnumerable<TDetail> DetailDelete { get; set; }
    }
    public class DataBulkDeletingEventArgs<TMain, TDetail> : EventArgs where TDetail : DBModel where TMain : DBModel
    {
        public bool Cancel { get; set; }
        public string Message { get; set; }
        public TMain Delete { get; set; }
        public IList<TDetail> DetailDelete { get; set; }
    }

    public class DataApprovingEventArgs<T> : EventArgs where T : DBModel
    {
        public bool Cancel { get; set; }
        public string Message { get; set; }
        public ApproveCode Status { get; set; }
        public T DataInDB { get; set; }
    }

    public class DataDeletingEventArgs<T> : EventArgs where T : DBModel
    {
        public bool Cancel { get; set; }
        public string Message { get; set; }
        public T Delete { get; set; }
    }
    public delegate void DataUpdatingHandler<T>(BaseUpdater<T> sender, DataUpdatingEventArgs<T> e) where T:DBModel;
    public delegate void DataBulkUpdatingHandler<TMain,TDetail>(MainDetailUpdater<TMain,TDetail> sender, DataBulkUpdatingEventArgs<TMain,TDetail> e)  where TDetail : DBModel where TMain : DBModel;
    public delegate void DataBulkDeletingHandler<TMain, TDetail>(MainDetailUpdater<TMain, TDetail> sender, DataBulkDeletingEventArgs<TMain, TDetail> e) where TDetail : DBModel where TMain : DBModel;
    public delegate void DataApprovingHandler<T>(BaseUpdater<T> sender, DataApprovingEventArgs<T> e) where T : DBModel;
    public delegate void DataDeletingHandler<T>(BaseUpdater<T> sender, DataDeletingEventArgs<T> e) where T : DBModel;
}
